package com.chinasoft.user.controller;

import com.chinasoft.user.domain.Business;
import com.chinasoft.user.service.BusinessService;
import com.chinasoft.user.vo.BusinessVo;
import com.chinasoft.utils.JedisPoolUtil;
import org.springframework.web.bind.annotation.*;
import redis.clients.jedis.Jedis;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 商家控制器
 */
@RestController
@CrossOrigin
@RequestMapping("bus")
public class BusinessController {

    private Jedis jedis = JedisPoolUtil.getJedis();

    @Resource
    private BusinessService businessService;

    /**
     * 查询所有商家，名称，地址
     * @param map
     * @return
     */
    @GetMapping("findAll")
    public List<BusinessVo> findAll(@RequestParam Map<String,Object> map){
        return businessService.findAll(map);
    }

    @GetMapping("findOne")
    public Business findOne(String jedisKey){
        String account = jedis.get(jedisKey);
        return businessService.findOne(account);
    }
}
